

#ifndef __EV_TCP_SERVER_H__
#define __EV_TCP_SERVER_H__

#include <string>
#include <vector>
#include <functional>
#include "ev_base.h"
#include <event2/event.h>

class EvTcpServer {
public:
    EvTcpServer(uint32_t client_max = 1);
    ~EvTcpServer();
    EvTcpServer(const EvTcpServer&) = delete;
    EvTcpServer& operator=(const EvTcpServer&) = delete;
    EvTcpServer(EvTcpServer&& other) = delete;
    EvTcpServer& operator=(EvTcpServer&& other) = delete;

public:
    int setCallBack(std::function<void(struct bufferevent*)> cb);

private:
    std::string name;
    struct evconnlistener *listener;
    std::vector<struct bufferevent*> clients;
    std::function<void(struct bufferevent*)> onRecvData_;
    uint32_t client_max;
    uint32_t timeout;
    uint32_t port;
};


#endif /* __EV_TCP_SERVER_H__ */